/*
 * @Descripttion: 
 * @version: 
 * @Author: mmzhang
 * @Date: 2021-07-23 09:45:29
 * @LastEditTime: 2022-02-18 09:28:15
 */

import table from '@/components/dt/table/render.js'
import nameOpt from '@/biz/option/name.js'
import dateOpt from '@/biz/option/date.js'
import Opt from '@/components/dt/info/Opt.js'
import dt from '@dt/dt'

let _this = null

class Column extends Opt {
  constructor(vm) {
    super()
    _this = vm
    this.build()
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }

  createAll() {
    this.all = [
      // {
      //   title: '序号',
      //   type: 'index',
      //   width: 80,
      //   align: 'center',
      // },
      {
        title: '渠道名称',
        field: 'channelName',
        minWidth: 120,
        align: 'center',
      },

      {
        title: '自获客打法',
        field: 'planName',
        minWidth: 120,
        align: 'center',

      }, {
        title: '是否渠道带看',
        field: 'isTakeLook',
        minWidth: 120,
        align: 'center',
        slots: {
          default: (params, h) => {
            return table.cell.text(h, {
              value: params.row.isTakeLook == '0' ? '否' : '是'
            })
          }
        }

      }, {
        title: '是否网络获客',
        field: 'isNetAcquire',
        minWidth: 120,
        align: 'center',
        slots: {
          default: (params, h) => {
            return table.cell.text(h, {
              value: params.row.isNetAcquire == '0' ? '否' : '是'
            })
          }
        }
      },

      {
        title: '渠道合作类型',
        field: 'cooperationTypeName',
        minWidth: 120,
        align: 'center',
      }, {
        title: '渠道费用',
        field: 'channelCostTypeName',
        minWidth: 120,
        align: 'center',

      },

      {
        title: '操作时间',
        field: 'operateTime',
        minWidth: 180,
        align: 'center',
      },
      {
        title: '操作人',
        field: 'operator',
        minWidth: 120,
        align: 'center',
      },
      {
        title: '状态',
        field: 'status',
        minWidth: 120,
        align: 'center',
        slots: {
          default: (params, h) => {
            return table.cell.text(h, {
              value: params.row.status == 1 ? '启用' : '禁用'
            })
          }
        }
      },
      {
        title: '操作',
        field: 'operation',
        width: 200,
        fixed: 'right',
        align: 'center',
        slots: {
          default: (params, h) => {
            let btns = []

            btns.push({
              title: (params.row.status == 1) ? '禁用' : '启用',
              event: 'channelStatus',
              data: params.row
            })
            return table.cell.btns(_this, h, btns)
          }
        }
      }
    ]
  }

}

export default Column